<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>17.3.BOM-定时器-setTimeout()-停止定时器</title>
    <style>

    </style>
</head>

<body>
    <button>点击停止定时器</button>
</body>

<script>
    window.addEventListener('load', function () {
        var btn = document.querySelector('button');
        var time1 = setTimeout(function () {
            console.log('5秒出现');
        }, 5000)
        btn.addEventListener('click', function () {
            clearTimeout(time1);
        })
    })
</script>

</html>